<?php
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thêm laptop</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery.ui.datepicker.js"></script>
<script>
$(document).ready(function() {
$("#ngaynhap").datepicker({
numberOfMonths: 1,  dateFormat: 'yy/mm/dd',
monthNames: ['Một','Hai','Ba','Tư','Năm','Sáu','Bảy','Tám','Chín', 
'Mười','Mười một','Mười hai'] ,
monthNamesShort: ['Tháng1','Tháng2','Tháng3','Tháng4','Tháng5',
'Tháng6','Tháng7','Tháng8','Tháng9','Tháng10','Tháng11','Tháng12'] ,
dayNames: ['Chủ nhật', 'Thứ hai', 'Thứ ba', 'Thứ tư', 'Thứ năm',
 'Thứ sáu', 'Thứ bảy'],
dayNamesMin: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'] ,
showWeek: true , showOn: 'both',
changeMonth: true , changeYear: true,
currentText: 'Hôm nay', weekHeader: 'Tuần'
});
});
</script>

<link href="jquery-ui-1.8.2.custom.css" rel="stylesheet" type="text/css" />
</head>

<body>
<?php
$idxoa = $_GET["idxoa"];
include("kn.php");

$lenh = "select * from laptop where malaptop='$idxoa'";
$kq = mysql_query($lenh);
$row = mysql_fetch_array($kq);


if(isset($_POST["xoa"]))
{
$lenhxoa = "delete from laptop where malaptop='$idxoa'";
$kqxoa = mysql_query($lenhxoa);
if($kqxoa)
?>
<script>
alert('Xóa thành công!');

</script>

<?php
header("refresh:2,url=thongtinlaptop.php");

}


?>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="550" border="1" align="center" cellpadding="0" cellspacing="0" style="border-collapse:collapse" bgcolor="#FFCC99" bordercolor="#FF9999">
    <tr>
      <td height="35" colspan="2" align="center" bgcolor="#FF9966">XÓA LAPTOP</td>
    </tr>
    <tr>
      <td width="178" style="padding-left:15px">Mã laptop</td>
      <td width="366"><label for="malaptop"></label>
      <input name="malaptop" type="text" id="malaptop" size="40" style="background:#F00" readonly="readonly" value="<?php echo $idxoa;   ?>" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Tên laptop</td>
      <td><label for="tenlaptop"></label>
      <input name="tenlaptop" type="text" id="tenlaptop" size="50" value="<?php echo $row[Tenlaptop];  ?>"/></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Hãng laptop</td>
      <td><label for="hang"></label>
        <select name="hang" id="hang">
        <?php
		$lenhhang = "select * from hanglaptop";
		$kqhang = mysql_query($lenhhang);
		while($rowhang = mysql_fetch_row($kqhang))
		{
			if($row[Mahanglaptop]==$rowhang[0])
			echo "<option value='$rowhang[0]'selected>$rowhang[1]</option>";
			else
			echo "<option value='$rowhang[0]'>$rowhang[1]</option>";
			
		}
		
		?>
       
      </select></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Loại laptop</td>
      <td><label for="loai"></label>
        <select name="loai" id="loai">
        <?php
		$lenhloai = "select * from loailaptop";
		$kqloai = mysql_query($lenhloai);
		while($rowloai = mysql_fetch_row($kqloai))
		{
			if($row[Maloailaptop]==$rowloai[0])
			echo "<option value='$rowloai[0]'selected>$rowloai[1]</option>";
			else
			echo "<option value='$rowloai[0]'>$rowloai[1]</option>";
			
		}
		
		?>
      </select></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Mô tả</td>
      <td><label for="mota"></label>
      <textarea name="mota" cols="30" rows="5" id="mota"><?php echo $row[Mota];   ?></textarea></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Số lượng</td>
      <td><label for="soluong"></label>
      <input name="soluong" type="text" id="soluong" size="30" value="<?php echo $row[Soluong];  ?>"/></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Đơn giá</td>
      <td><label for="dongia"></label>
      <input name="dongia" type="text" id="dongia" size="30" value="<?php echo $row[Dongia];  ?>"/></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Hình</td>
      <td><label for="hinh"></label>
      <input type="file" name="hinh" id="hinh" /></td>
    </tr>
    <tr>
      <td style="padding-left:15px">Ngày nhập</td>
      <td><label for="ngaynhap"></label>
      <input name="ngaynhap" type="text" id="ngaynhap" size="40" value="<?php echo $row[Ngaynhap];   ?>"/></td>
    </tr>
    <tr>
      <td height="35" colspan="2" align="center"><input type="submit" name="xoa" id="xoa" value="Xóa laptop" /></td>
    </tr>
  </table>
</form>
</body>
</html>